//
//  OnlineVideoAssetTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/9/4.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "OnlineVideoAssetTableViewCell.h"

@implementation OnlineVideoAssetTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initMyCell];
    }
    return self;
}


-(void)initMyCell{
    [self.contentView addSubview:self.titleImageView];
    [self.contentView addSubview:self.ybTitleLabel];
    [self.contentView addSubview:self.clickNumberLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.bottomView];
    
    self.titleImageView.sd_layout.leftSpaceToView(self.contentView , ItemWidth * 24).topSpaceToView(self.contentView , ItemHeight * 23).widthIs(ItemWidth * 277).bottomSpaceToView(self.contentView , ItemHeight * 25);
    
    self.ybTitleLabel.sd_layout.leftSpaceToView(self.titleImageView , ItemWidth * 18).topSpaceToView(self.contentView , ItemHeight * 24).widthIs(1).heightIs(1);
    
    self.clickNumberLabel.sd_layout.leftSpaceToView(self.titleImageView , ItemWidth * 18).bottomSpaceToView(self.contentView , ItemHeight * 21).widthIs(ItemWidth * 200).heightIs(ItemHeight * 40);
    
    self.timeLabel.sd_layout.leftSpaceToView(self.clickNumberLabel , ItemWidth * 7).bottomSpaceToView(self.contentView , ItemHeight * 21).widthIs(ItemWidth * 200).heightIs(ItemHeight * 40);
    
    self.bottomView.sd_layout.leftSpaceToView(self.contentView , 0).bottomSpaceToView(self.contentView , 0).rightSpaceToView(self.contentView , 0).heightIs(ItemHeight * 3);
}


-(void)setModel:(OnlineVideoAssetModel *)model
{
    _model = model;
    self.ybTitleLabel.sd_layout.leftSpaceToView(self.titleImageView , ItemWidth * 18).topSpaceToView(self.contentView , ItemHeight * 24).widthIs(model.titleSize.width).heightIs(model.titleSize.height + 1);
    [self.ybTitleLabel updateLayout];
    self.ybTitleLabel.attributedText = model.titleAttributedString;
    [self.titleImageView sd_setImageWithURL:CREATEURL(model.IMAGEPHOTO_THUMBURL) placeholderImage:PlaceholderImage];
    self.ybTitleLabel.attributedText = model.titleAttributedString;
    NSString * clickNumberString = @"0";
    if (model.CLICKRATE.length > 0) {
        clickNumberString = model.CLICKRATE;
    }
    self.clickNumberLabel.text = [NSString stringWithFormat:@"点击数：%@" , clickNumberString];
    self.timeLabel.text = [NSString stringWithFormat:@"%@" , model.CREATETIME];
}


-(UIImageView *)titleImageView
{
    if (!_titleImageView) {
        _titleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(1, 1, 1, 1)];
    }
    return _titleImageView;
}


-(UILabel *)ybTitleLabel
{
    if (!_ybTitleLabel) {
        _ybTitleLabel = [ToolClass creatLabelWithFrame:CGRectMake(1, 1, 1, 1) font:16 textColor:[UIColor textBlackColor] text:@""];
        _ybTitleLabel.numberOfLines = 2;
    }
    return _ybTitleLabel;
}

-(UILabel *)clickNumberLabel
{
    if (!_clickNumberLabel) {
        _clickNumberLabel = [ToolClass creatLabelWithFrame:CGRectMake(1, 1, 1, 1) font:14 textColor:[UIColor textLightGrayColor] text:@""];
    }
    return _clickNumberLabel;
}


-(UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = [ToolClass creatLabelWithFrame:CGRectMake(1, 1, 1, 1) font:14 textColor:[UIColor textLightGrayColor] text:@""];
        _timeLabel.textAlignment = NSTextAlignmentRight;
    }
    return _timeLabel;
}

-(UIView *)bottomView
{
    if (!_bottomView) {
        _bottomView = [[UIView alloc]initWithFrame:CGRectMake(1, 1, 1, 1)];
        _bottomView.backgroundColor = [UIColor themeGrayColor];
    }
    return _bottomView;
}

@end
